SCREENSHOT_SUCCESS = ""



local name = UnitName("player")
local realm = GetRealmName()
local level = UnitLevel("player")
local race = UnitRace("player")
local class = UnitClass("player")
local faction = UnitFactionGroup("player")
local playerInfo = 55



local backgroundOverlay = CreateFrame("FRAME")
backgroundOverlay:SetFrameLevel(0)
backgroundOverlay:SetPoint("TOP", WorldFrame, "TOP", 0, -35)
backgroundOverlay:SetSize(GetScreenWidth(), 64)
backgroundOverlay:SetBackdrop({ bgFile = "Interface\\AddOns\\ElegantScreenshot\\Textures\\White8x8" })
backgroundOverlay:SetBackdropColor(0, 0, 0, .5)
backgroundOverlay:Hide()



local backgroundOverlay2 = CreateFrame("FRAME")
backgroundOverlay2:SetFrameStrata("FULLSCREEN")
backgroundOverlay2:SetFrameLevel(0)
backgroundOverlay2:SetPoint("CENTER", WorldFrame, "CENTER", 0, 0)
backgroundOverlay2:SetSize(GetScreenWidth(), GetScreenHeight())
backgroundOverlay2:SetBackdrop({ bgFile = "Interface\\AddOns\\ElegantScreenshot\\Textures\\White8x8" })
backgroundOverlay2:SetBackdropColor(1, 1, 1, 1)
backgroundOverlay2:Hide()



local characterButton = CreateFrame("FRAME", nil, characterButtons)
characterButton:SetFrameLevel(5)
characterButton:CreateFontString("characterButton_TEXT", "ARTWORK")
characterButton_TEXT:SetFont("Interface\\AddOns\\ElegantScreenshot\\Fonts\\Tahoma.ttf", 18, "OUTLINE")
characterButton_TEXT:SetPoint("LEFT", backgroundOverlay, "LEFT", 185, 10)
characterButton_TEXT:SetText(name)
characterButton:Hide()



local characterButton2 = CreateFrame("FRAME")
characterButton2:SetFrameLevel(5)
characterButton2:CreateFontString("characterButton2_TEXT", "ARTWORK")
characterButton2_TEXT:SetFont("Interface\\AddOns\\ElegantScreenshot\\Fonts\\Bilbo.ttf", 18, "OUTLINE")
characterButton2_TEXT:SetPoint("RIGHT", characterButton_TEXT, "RIGHT", 25, -20)
characterButton2_TEXT:SetText("of " .. realm)
characterButton2:Hide()



local characterButton3 = CreateFrame("FRAME")
characterButton3:SetFrameLevel(5)
characterButton3:CreateFontString("characterButton3_TEXT", "ARTWORK")
characterButton3_TEXT:SetFont("Interface\\AddOns\\ElegantScreenshot\\Fonts\\Tahoma.ttf", 10, "OUTLINE")
characterButton3_TEXT:SetPoint("RIGHT", backgroundOverlay, "RIGHT", -185, 14)
characterButton3_TEXT:SetText("Level " .. level)
characterButton3:Hide()



local characterButton4 = CreateFrame("FRAME")
characterButton4:SetFrameLevel(5)
characterButton4:CreateFontString("characterButton4_TEXT", "ARTWORK")
characterButton4_TEXT:SetFont("Interface\\AddOns\\ElegantScreenshot\\Fonts\\Tahoma.ttf", 10, "OUTLINE")
characterButton4_TEXT:SetPoint("CENTER", characterButton3_TEXT, "CENTER", 0, -12)
characterButton4_TEXT:SetText(race .. " " .. class)
characterButton4:Hide()



local characterButton6 = CreateFrame("FRAME")
characterButton6:SetFrameLevel(5)
characterButton6:CreateFontString("characterButton6_TEXT", "ARTWORK")
characterButton6_TEXT:SetFont("Interface\\AddOns\\ElegantScreenshot\\Fonts\\Tahoma.ttf", 10, "OUTLINE")
characterButton6_TEXT:SetPoint("CENTER", characterButton3_TEXT, "CENTER", 0, -24)
characterButton6:Hide()



local battleNetLogo = CreateFrame("FRAME", nil, backgroundOverlay)
battleNetLogo_TEX = battleNetLogo:CreateTexture(nil, "ARTWORK")
battleNetLogo_TEX:SetSize(128, 128)
battleNetLogo_TEX:SetPoint("LEFT", backgroundOverlay, "LEFT", 75, 0)
battleNetLogo:Hide()



local battleNetLogo2 = CreateFrame("FRAME", nil, backgroundOverlay)
battleNetLogo2_TEX = battleNetLogo:CreateTexture(nil, "ARTWORK")
battleNetLogo2_TEX:SetSize(128, 128)
battleNetLogo2_TEX:SetPoint("LEFT", backgroundOverlay, "LEFT", 75, 0)
battleNetLogo2:Hide()



local testa = CreateFrame("Frame")
testa:RegisterEvent("PLAYER_LOGIN")
testa:SetScript("OnEvent", function()
      if faction == "Horde" then
         battleNetLogo_TEX:SetTexture("Interface\\Timer\\Horde-Logo")
      elseif faction == "Alliance" then
         battleNetLogo2_TEX:SetTexture("Interface\\Timer\\Alliance-Logo")
      end
end)



local zoneA = CreateFrame("FRAME")
zoneA:SetFrameLevel(5)
zoneA:CreateFontString("zoneA_TEXT", "ARTWORK")
zoneA_TEXT:SetFont("Interface\\AddOns\\ElegantScreenshot\\Fonts\\Bilbo.ttf", 24, "OUTLINE")
zoneA_TEXT:SetPoint("BOTTOM", WorldFrame, "BOTTOM", 0, 25)
zoneA:Hide()



local testc = CreateFrame("Frame")
testc:RegisterEvent("SCREENSHOT_SUCCEEDED")
testc:SetScript("OnEvent", function()
      PlaySoundFile("Interface\\AddOns\\ElegantScreenshot\\Sounds\\Shutter.ogg", "MASTER")
      UIFrameFlash(backgroundOverlay2, .15,.15,.3, false,0,0)
end)



local testb = CreateFrame("Frame")
testb:RegisterEvent("ZONE_CHANGED")
testb:RegisterEvent("ZONE_CHANGED_INDOORS")
testb:RegisterEvent("ZONE_CHANGED_NEW_AREA")
testb:RegisterEvent("PLAYER_ENTERING_WORLD")
testb:SetScript("OnEvent", function()
      zone = GetZoneText()
      zoneA_TEXT:SetText(zone)
end)



function onUpdate(self, elapsed)
	playerInfo = playerInfo + elapsed
	if playerInfo >= 60 then
		
		local guildName, guildRankName, guildRankIndex = GetGuildInfo("player")
		characterButton6_TEXT:SetText("<" .. guildName  .. ">")
				
		if (guildName == nil) then
			characterButton6_TEXT:SetText("Unguilded")
			else
			characterButton6_TEXT:SetText("<" .. guildName .. ">")
		end
		
		playerInfo = 0
	end
end



local systemTimeLoopFrame = CreateFrame("FRAME")
systemTimeLoopFrame:SetScript("OnUpdate", onUpdate)



local test = CreateFrame("Frame")
test:RegisterEvent("MODIFIER_STATE_CHANGED")
test:SetScript("OnEvent", function()
      if UIParent:IsVisible() then
         backgroundOverlay:Hide()
         characterButton:Hide()
         characterButton2:Hide()
         characterButton3:Hide()
         characterButton4:Hide()
         characterButton6:Hide()
         battleNetLogo:Hide()
         battleNetLogo2:Hide()
         zoneA:Hide()
      else
         backgroundOverlay:Show()
         characterButton:Show()
         characterButton2:Show()
         characterButton3:Show()
         characterButton4:Show()
         characterButton6:Show()
         battleNetLogo:Show()
         battleNetLogo2:Show()
         zoneA:Show()
      end
end)